#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author:nigo

def pv(A,r,n):
    """年金现值函数
    A:年金
    r:利率
    n:期数
    return:现值
    """
    pv = 0
    for i in range(1,n+1):
        pv += A / pow((1+r),i)
    return pv


result = pv(5000,0.04,30)
print(result)

